package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feignclients.product.CategoryFeginClient;
import com.atguigu.gmall.weball.CategoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @ClassName IndexController
 * @Description TODO
 * @Author king
 * @Date 2022/11/3 17:25
 * @Version 1.0
 */
@Controller //页面跳转
public class IndexController {

    @Autowired
    CategoryFeginClient client;

    @GetMapping({"/", "/index.html"})
    public String indexPage(Model model){

        Result<List<CategoryVO>> categoryTree = client.getCategoryTree();

        //远程调用
        List<CategoryVO> vos = categoryTree.getData();
        model.addAttribute("list", vos);
        return "index/index";
    }

}
